package com.hds;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ObjectCollectionSort implements Comparable<ObjectCollectionSort> {

    private Integer number;

    private String name;

    public ObjectCollectionSort(Integer number, String name) {
        this.number = number;
        this.name = name;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "ObjectCollectionSort{" +
                "number=" + number +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(ObjectCollectionSort o) {
       // System.out.println("======"+this.getNumber());
//        System.out.println("======"+o.getNumber());
        return this.getNumber() - o.getNumber();
        //        if(this.number == o.getNumber()){
//            return 0;
//        }else if(this.number > o.getNumber()){
//            return -1;
//        }else{
//            return 1;
//        }
    }

    public static void main(String[] args) {
        List<ObjectCollectionSort> list = new ArrayList<ObjectCollectionSort>();
        ObjectCollectionSort o0=new ObjectCollectionSort(2,"zzz");
        ObjectCollectionSort o1=new ObjectCollectionSort(5,"aa");
        ObjectCollectionSort o2=new ObjectCollectionSort(1,"uu");
        ObjectCollectionSort o3=new ObjectCollectionSort(4,"gg");
        list.add(o0);
        list.add(o1);
        list.add(o2);
        list.add(o3);

//        ObjectCollectionSort[] objectCollectionSorts = new ObjectCollectionSort[]{
//                new ObjectCollectionSort(4, "张三"),
//                new ObjectCollectionSort(2, "赵四"),
//                new ObjectCollectionSort(1, "赵四"),
//                new ObjectCollectionSort(3, "赵四")
//        };

       // Arrays.sort(objectCollectionSorts);
        Collections.sort(list);
//        System.out.println(Arrays.toString(objectCollectionSorts));
        System.out.println(list.toString());
        System.out.println("===max==="+Collections.max(list).toString());
        System.out.println("===min==="+Collections.min(list).toString());
    }

}
